﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;


namespace wp8nop.Model
{
   
    public class ProdottoViewModel : ViewModelBase
    {
        public ProdottoViewModel(nopService.products mod)
        {
            Model = mod;
        }

        public nopService.products Model { get; set; }
        /// <summary>
        /// The <see cref="Quantita" /> property's name.
        /// </summary>
        public const string QuantitaPropertyName = "Quantita";

        private int _quantita = 1;

        /// <summary>
        /// Sets and gets the Quantita property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public int Quantita
        {
            get
            {
                return _quantita;
            }

            set
            {
                if (_quantita == value)
                {
                    return;
                }

                RaisePropertyChanging(QuantitaPropertyName);
                _quantita = value;
                RaisePropertyChanged(QuantitaPropertyName);
                RaisePropertyChanged("QuantitaDesc");
            }
        }

        public string QuantitaDesc
        {
            get
            {
                return string.Format("Quantità: {0}", Quantita);
            }
        }

        public string OriginalPrice
        {
            get
            {
                return string.Format("{0:F2}€", Model.origprice);
            }
        }

        public string Price
        {
            get
            {
                return string.Format("{0:F2}€", Model.price);
            }
        }


        public Visibility IsSpedizioneGratis
        {
            get
            {
                return Model.price >= 60 ? Visibility.Visible : Visibility.Collapsed;
                  
            }
        }

        public string PrezzoSpedizione
        {
            get
            {
                if (Model.price >= 60)
                    return "Spedizione gratuita";
                else
                    return null;
            }
        }

        public string Spedizione {
            get 
            {
                var descSped = "";
                if (Model.ship == 1)
                    descSped = "Spedito in 24 ore";
                else if (Model.ship == 2)
                    descSped = "Spedito in 48 ore";
                else
                    descSped = "Spedito in " + Model.ship + " giorni";

                return descSped;
            }

        }
    }
}



//namespace nopService
//{
//    public class products
//    { }
//}
